<template>
  <el-dropdown class="lang" @command="change">
    <span class="el-dropdown-link">
      <svg-icon class="icon" fill="#fff" icon-class="language" />
    </span>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="zh" :disabled="$i18n.locale === 'zh'">中文</el-dropdown-item>
      <el-dropdown-item command="en" :disabled="$i18n.locale === 'en'">English</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
export default {

  methods: {
    change(cmd) {
      // 改变i18n
      this.$i18n.locale = cmd
      // 存到本地
      localStorage.setItem('lang', cmd)
    }
  }
}
</script>

<style scoped lang="scss">
.lang {
  margin-right: 10px;
  .icon {
    font-size: 20px;
    color: #fff;
  }
}
</style>
